package part19;

/**
 * @author wcj
 * @Date 2021/6/5 20:16
 * @Version 1.0
 */
public class Part1911 {
}

/**
 * 责任链模式：即对于同一个问题采用不同的解决方式
 * 一一尝试，最终找到能解决问题的方式
 */
class Mail {
    enum GeneralDelivery {YES, NO1, NO2, NO3, NO4, NO5}

    enum Scannability {UNSCANNABLE, YES1, YES2, YES3, YES4}

    enum Reabdability {ILLEGIBLE, YES1, YES2, YES3, YES4}

    enum Address {INCORRECT, OK1, OK2, OK3, OK4, OK5, OK6}

    enum ReturnAddress {MISSING, OK1, OK2, OK3, OK4, OK5}

    GeneralDelivery generalDelivery;
    Scannability scannability;
    Reabdability reabdability;
    Address address;
    ReturnAddress returnAddress;
    static int counter = 0;
    long id = counter++;

    @Override
    public String toString() {
        return "Mail: " + id;
    }

    public String details() {
        return toString() + "General Delivery:" + generalDelivery +
                ",Address Scanability:" + scannability +
                ",Address Readability:" + reabdability +
                ",Address address:" + address +
                ",Return address:" + returnAddress;
    }

    public static Mail randomMail() {
        Mail mail = new Mail();
        mail.generalDelivery = Part196.random(GeneralDelivery.class);
        mail.scannability = Part196.random(Scannability.class);
        mail.reabdability = Part196.random(Reabdability.class);
        mail.address = Part196.random(Address.class);
        mail.returnAddress = Part196.random(ReturnAddress.class);
        return mail;
    }
}
